// router.js
import {
	RouterMount,
	createRouter
} from 'uni-simple-router';

import {
	myCheckToken
} from '@/apis/login.js';

const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,
	routes: [...ROUTES]
});
//全局路由前置守卫
router.beforeEach(async (to, from, next) => {
	console.log('to======', to);
	console.log('from======', from);
	// if (res[1].statusCode === 400) next('/pages/login/login');
	// if(!res[1].data.success)return  next('/pages/login/login');
	if (to.fullPath === from.fullPath) return
	// if (to.fullPath !== '/pages/login/login') {
	// 	let token = uni.getStorageSync('token')
	// 	if (token) {
	// 		next()
	// 	} else {
	// 		uni.navigateTo({
	// 			url: '/pages/login/login?path=' + to.path
	// 		})
	// 	}
	// } else {
	next();
	// }

	next();
});
// 全局路由后置守卫
router.afterEach((to, from) => {
	console.log('跳转结束')
})

export {
	router,
	RouterMount
}
